function optimizeintpar(calib_data)
options=optimset('Display','final',...
                 'LargeScale','on', ...
                 'TolX',1e-4,...
                 'TolFun',1e-4,...
                 'DerivativeCheck','off',...
                 'Diagnostics','off',...
                 'Jacobian','off',...
                 'JacobMult',[],... % JacobMult set to [] by default
                 'JacobPattern','sparse(ones(Jrows,Jcols))',...
                 'MaxFunEvals','100*numberOfVariables',...
                 'DiffMaxChange',1e-1,...
                 'DiffMinChange',1e-8,...
                 'PrecondBandWidth',0,...
                 'TypicalX','ones(numberOfVariables,1)',...
                 'MaxPCGIter','max(1,floor(numberOfVariables/2))', ...
                 'TolPCG',0.1,...
                 'MaxIter',10000,...
                 'LineSearchType','quadcubic',...
                 'LevenbergMarquardt','on'); 

if (isempty(calib_data.ocam_model.c) & isempty(calib_data.ocam_model.d) & isempty(calib_data.ocam_model.e))
    calib_data.ocam_model.c=1;
    calib_data.ocam_model.d=0;
    calib_data.ocam_model.e=0;
end
int_par=[calib_data.ocam_model.c,calib_data.ocam_model.d,calib_data.ocam_model.e,calib_data.ocam_model.xc,calib_data.ocam_model.yc];

[ssout,resnorm,residual,exitflag,output] =lsqnonlin(@prova2,int_par,-inf,inf,options,calib_data.ocam_model.ss,calib_data.RRfin, calib_data.ima_proc,calib_data.Xp_abs,calib_data.Yp_abs,M, calib_data.ocam_model.width, calib_data.ocam_model.height);
fprintf(1,'Camera model optimized');


c=ssout(1)
d=ssout(2)
e=ssout(3)
xc=ssout(4)
yc=ssout(5)

%calib_data.ocam_model.ss=ss;
calib_data.ocam_model.xc=xc;
calib_data.ocam_model.yc=yc;
calib_data.ocam_model.c=c;
calib_data.ocam_model.d=d;
calib_data.ocam_model.e=e;
%calib_data.ocam_model.width=width;
%calib_data.ocam_model.height=height;
reprojectpoints_adv(calib_data.ocam_model, calib_data.RRfin, calib_data.ima_proc, calib_data.Xp_abs, calib_data.Yp_abs, M);
calib_data.ocam_model.ss


